<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="test.css">
</head>
<body >

<div id="content"></div>

</body>
<script src="index1.js"></script>
<script>
    var parDiv=document.getElementById("content");
    var leftX=parDiv.offsetLeft;
    var topY=parDiv.offsetTop;
    function creatDiv() {
       this.oDiv=document.createElement("div");
       this.oDiv.style.width="20px";
       this.oDiv.style.height="20px";
       this.oDiv.style.borderRadius="10px";
       this.oDiv.style.backgroundColor="red";
       this.oDiv.style.position="absolute";

    }
    creatDiv.prototype.move=function () {
        var self=this;
        setInterval(function () {
            self.oDiv.style.left=parseInt(Math.random()*800)+"px";
            self.oDiv.style.top=parseInt(Math.random()*400)+"px";
        },500)
    };
    for(var i=0;i<10;i++){
        var xt=new creatDiv();
        xt.move();
        parDiv.appendChild(xt.oDiv)
    }

</script>
</html>